home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / djgpp / diffs / make-3.71 / main.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-05  |  2.2 KB  |  79 lines

  1. *** orig/make-3.71/main.c    Thu Jul 21 01:30:06 1994
  2. --- src/make-3.71/main.c    Thu Jul 21 02:16:02 1994
  3. ***************
  4. *** 316,321 ****
  5. --- 316,325 ----
  6.   
  7.   char *starting_directory;
  8.   
  9. + /* Our current directory before processing any -C options.  */
  10. + char *directory_before_chdir;
  11.   /* Value of the MAKELEVEL variable at startup (or 0).  */
  12.   
  13.   unsigned int makelevel;
  14. ***************
  15. *** 394,400 ****
  16.     register struct dep *lastgoal;
  17.     struct dep *read_makefiles;
  18.     PATH_VAR (current_directory);
  19. -   char *directory_before_chdir;
  20.   
  21.     default_goal_file = 0;
  22.     reading_filename = 0;
  23. --- 398,403 ----
  24. ***************
  25. *** 464,469 ****
  26. --- 467,478 ----
  27.     else 
  28.       {
  29.         program = rindex (argv[0], '/');
  30. + #ifdef __MSDOS__
  31. +       if (program == 0)
  32. +         program = rindex (argv[0], '\\');
  33. +       if (program == 0)
  34. +         program = rindex (argv[0], ':');
  35. + #endif
  36.         if (program == 0)
  37.       program = argv[0];
  38.         else
  39. ***************
  40. *** 601,606 ****
  41. --- 610,616 ----
  42.       }
  43.     free (cmd_defs);
  44.   
  45. + #ifndef __MSDOS__
  46.     /* Set the "MAKE_COMMAND" variable to the name we were invoked with.
  47.        (If it is a relative pathname with a slash, prepend our directory name
  48.        so the result will run the same program regardless of the current dir.
  49. ***************
  50. *** 610,615 ****
  51. --- 620,626 ----
  52.     if (current_directory[0] != '\0'
  53.         && argv[0] != 0 && argv[0][0] != '/' && index (argv[0], '/') != 0)
  54.       argv[0] = concat (current_directory, "/", argv[0]);
  55. + #endif /* __MSDOS__ */
  56.   
  57.     (void) define_variable ("MAKE_COMMAND", 12, argv[0], o_default, 0);
  58.   
  59. ***************
  60. *** 1752,1757 ****
  61. --- 1763,1777 ----
  62.     if (!dying)
  63.       {
  64.         int err;
  65. +       /* On some systems, especially MS-DOS, the current directory is a
  66. +      system value, not a per-process value, so we must restore our
  67. +      original directory or we find ourselves in some other directory
  68. +      after make finishes.  On unix, this doesn't hurt, and will make
  69. +      sure the core file is in the "expected" place if we core dump
  70. +      on exit */
  71. +       if (directory_before_chdir)
  72. +     chdir (directory_before_chdir);
  73.   
  74.         dying = 1;
  75.   
  76.